home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 22 / CU Amiga Magazine's Super CD-ROM 22 (1998)(EMAP Images)(GB)[!][issue 1998-05].iso / PowerPC / Programming / PPCSmallEiffel / lib_se / proc_call_1.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.4 KB  |  145 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class PROC_CALL_1
  17.    --
  18.    -- For a procedure call with only one argument.
  19.    --   
  20.  
  21. inherit 
  22.    PROC_CALL
  23.       redefine use_current
  24.       end;
  25.  
  26. creation make
  27.    
  28. feature 
  29.    
  30.    arguments: EFFECTIVE_ARG_LIST; 
  31.    
  32. feature 
  33.    
  34.    make(t: like target; pn: like feature_name; a: like arguments) is
  35.       require
  36.      t /= Void;
  37.      pn /= Void;
  38.      a /= Void;
  39.       do
  40.      target := t;
  41.      feature_name := pn;
  42.      arguments := a;
  43.       ensure
  44.      target = t;
  45.      feature_name = pn;
  46.      arguments = a;
  47.       end;
  48.  
  49.    arg_count: INTEGER is 1;
  50.  
  51.    arg1: EXPRESSION is
  52.       do
  53.      Result := arguments.first;
  54.       end;
  55.    
  56.    to_runnable(rc: like run_compound): like Current is
  57.       local
  58.      a: like arguments;
  59.       do
  60.      if run_compound = Void then
  61.         to_runnable_0(rc);
  62.         if nb_errors = 0 then
  63.            a := arguments.to_runnable(current_type);
  64.            if a = Void then
  65.           error(arg1.start_position,fz_bad_argument);
  66.            else
  67.           arguments := a;
  68.            end;
  69.         end;
  70.         if nb_errors = 0 then
  71.            arguments.match_with(run_feature); 
  72.         end;
  73.         if nb_errors = 0 then
  74.            Result := Current;
  75.         end;
  76.      else
  77.         !!Result.make(target,feature_name,arguments);
  78.         Result := Result.to_runnable(rc);
  79.      end;
  80.       end;
  81.    
  82.    compile_to_jvm is
  83.       do
  84.      if us_c_inline_c = feature_name.to_string then
  85.         eh.add_position(start_position);
  86.         fatal_error("Cannot use %"c_inline_c%" to produce Java byte code.");
  87.      else
  88.         call_proc_call_c2jvm;
  89.      end;
  90.       end;
  91.  
  92.    use_current: BOOLEAN is
  93.       local
  94.      ms: MANIFEST_STRING;
  95.      s: STRING;
  96.       do
  97.      if us_c_inline_c = feature_name.to_string then
  98.         ms ?= arg1;
  99.         check
  100.            ms /= Void
  101.         end;
  102.         s := ms.to_string;
  103.         Result := s.has('C');
  104.      else
  105.         Result := standard_use_current;
  106.      end;
  107.       end;
  108.   
  109.    pretty_print is
  110.       do
  111.      target.print_as_target;
  112.      fmt.put_string(feature_name.to_string);
  113.      fmt.put_character('(');
  114.      arg1.pretty_print;
  115.      fmt.put_character(')');
  116.      if fmt.semi_colon_flag then
  117.         fmt.put_character(';');
  118.      end;
  119.       end;
  120.    
  121. feature {CREATION_CALL}
  122.  
  123.    make_runnable(rc: like run_compound; 
  124.          w: like target; a: like arguments;
  125.          rf: RUN_FEATURE): like Current is
  126.       do
  127.      if run_compound = Void then
  128.         Result := Current;
  129.         Result.make(w,feature_name,a);
  130.         run_compound := rc;
  131.         run_feature := rf;
  132.      else
  133.         !!Result.make(w,feature_name,a);
  134.         Result.set_run_compound(rc);
  135.         Result.set_run_feature(rf);
  136.      end;
  137.       end;
  138.  
  139. invariant   
  140.    
  141.    arguments.count = 1
  142.    
  143. end -- PROC_CALL_1
  144.  
  145.